package com.yc.behavioral.strategy.context.impl;

import com.yc.behavioral.strategy.CalcStrategy;
import com.yc.behavioral.strategy.impl.AddStrategy;
import com.yc.behavioral.strategy.impl.DivStrategy;
import com.yc.behavioral.strategy.impl.MulStrategy;
import com.yc.behavioral.strategy.impl.SubStrategy;
import org.junit.Test;

public class CalculatorContext  {

	private CalcStrategy calcStrategy;

	public CalculatorContext() {
	}

	public CalculatorContext(CalcStrategy calcStrategy) {
		this.calcStrategy = calcStrategy;
	}
	public void execute(Double num1, Double num2) {
		Double result = this.calcStrategy.execuCalc(num1, num2);
		System.out.println(result);
	}

	public static void main(String[] args) {
		// 加
		CalculatorContext c1 = new CalculatorContext(new AddStrategy());
		c1.execute(1.0d, 2.1d);
		// 减法
		CalculatorContext c2 = new CalculatorContext(new SubStrategy());
		c2.execute(5.0d, 2.1d);
		// 乘法
		CalculatorContext c3 = new CalculatorContext(new MulStrategy());
		c3.execute(5.0d, 2.1d);
		// 除法
		CalculatorContext c4 = new CalculatorContext(new DivStrategy());
		c4.execute(5.0d, 2.1d);

	}
	@Test
	public void aa(){
		System.out.println("1");
	}
}
